/**
 * 
 */
package com.ntv.persistent.astrology;

import java.util.Date;
import java.util.List;

import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
import org.springframework.jdbc.core.namedparam.SqlParameterSource;

import com.ntv.domain.IZodiacZone;
import com.ntv.persistent.AbstractDao;
import com.ntv.persistent.PersistentException;

/**
 * @author Vedamoorthi Vairam
 * @since 12/02/2009
 *
 */
public class AstrologyDao  extends AbstractDao implements IAstrologyDao
{

	interface CONST 
	{
		interface QUERY 
		{
			final String GET_ASTROLOGY_BY_DATE = "select id, " +			
			"zodiac_zone_id, " +
			"date, " +
			"description, " +
			"created_by, " +
			"created_on, " +
			"updated_by, " +
			"updated_on" +
			" where DATE_FORMAT(news_date,'%Y%m%d') = DATE_FORMAT(now(),'%Y%m%d')" +
			" limit 0, 50";
			
	
		}
	}

	public List<IZodiacZone> findAstrologyListByDate(Date date)  throws PersistentException {
		try {
			SqlParameterSource namedParameters = new MapSqlParameterSource("date", date);	
			List<IZodiacZone> newsList = (List<IZodiacZone>)getNamedParameterJdbcTemplate().query(CONST.QUERY.GET_ASTROLOGY_BY_DATE, namedParameters,
					getRowMapper());
			return newsList;
		}catch (DataAccessException ex) {
			throw new PersistentException(ex);
		}
	}
}
